#define BIT(x)	(1 << (x))
#define	AX1() (PINL&BIT(1))
#define	AY1() (PINL&BIT(0))
#define	AZ1() (PIND&BIT(4))
#define	AX2() (PINJ&BIT(1))
#define	AY2() (PINK&BIT(0))
#define	AZ2() (PINB&BIT(0))
#define	SAV() (PINK&BIT(7))
#define	Ae() (PINK&BIT(1))
#define	Qg() (PINJ&BIT(1))
#define	Qt() (PINJ&BIT(2))
#define	Zin1() (PIND&BIT(1))
#define	Zin2() (PINE&BIT(6))
#define	Halt() (PIND&BIT(5))
#define	FAe() (PINH&BIT(1))

#define Sg_ON      PORTF |= BIT(1)
#define St_ON      PORTF |= BIT(2)
#define CE_ON      PORTH |= BIT(6)
#define RED_ON     PORTL |= BIT(2)
#define BLUE_ON    PORTL |= BIT(6)
#define GREEN_ON   PORTG |= BIT(4)
#define Z1_ON      PORTB |= BIT(3)
#define Z2_ON      PORTB |= BIT(4)
#define OL_ON      PORTK |= BIT(4)
#define XU_ON      PORTK |= BIT(2)
#define WT_ON      PORTK |= BIT(3)
#define HP_ON      PORTE |= BIT(4)
#define ZRise_ON   PORTE |= BIT(2)
#define ZDown_ON   PORTH |= BIT(2)
#define GSelect_ON PORTH |= BIT(4)
#define HP1_ON     PORTL |= BIT(4)
#define HP2_ON     PORTL |= BIT(3)

#define Sg_OFF      PORTF &= ~BIT(1)
#define St_OFF      PORTF &= ~BIT(2)
#define CE_OFF      PORTH &= ~BIT(6)
#define RED_OFF     PORTL &= ~BIT(2)
#define BLUE_OFF    PORTL &= ~BIT(6)
#define GREEN_OFF   PORTG &= ~BIT(4)
#define Z1_OFF      PORTB &= ~BIT(3)
#define Z2_OFF      PORTB &= ~BIT(4)
#define OL_OFF      PORTK &= ~BIT(4)
#define XU_OFF      PORTK &= ~BIT(2)
#define WT_OFF      PORTK &= ~BIT(3)
#define HP_OFF      PORTE &= ~BIT(4)
#define ZRise_OFF   PORTE &= ~BIT(2)
#define ZDown_OFF   PORTH &= ~BIT(2)
#define GSelect_OFF PORTH &= ~BIT(4)
#define HP1_OFF     PORTL &= ~BIT(4)
#define HP2_OFF     PORTL &= ~BIT(3)
